/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package rg1exceptiondemo;

/**
 *
 * @author apple
 */
public class AddNum 
{
    private int num1;
    private int num2;
    

    public AddNum() {
    }

    public AddNum(int num1, int num2) {
        this.num1 = num1;
        this.num2 = num2;
    }

    public int getNum1() {
        return num1;
    }

    public void setNum1(int num1) {
        this.num1 = num1;
    }

    public int getNum2() {
        return num2;
    }

    public void setNum2(int num2) {
        this.num2 = num2;
    }
    
    public int getSum() throws NumberRangeException
            
    {
        if(num1<10||num1>20||num2<10||num2>20)
        {
            NumberRangeException numberRangeException=new NumberRangeException("num1或num2不在指定的计算范围内，无法进行计算："+num1+"  ,"+num2);
            throw numberRangeException;
        }
        return num1+num2;
    }
}
